﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows;
using System.Timers;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using ScreensInterfaces;
using ScreensRepo;

namespace RepresentationLayer
{
    public class WPFUserInterface : IRepresentationLayer
    {
        private GetMessageScreen inputScreen;
        private ShowMessageScreen showMsgScreen;
        private ShowTwoChoicesScreen showTwoChoicesScreen;

        public WPFUserInterface()
        {
            inputScreen = new GetMessageScreen();
            showMsgScreen = new ShowMessageScreen();
            showTwoChoicesScreen = new ShowTwoChoicesScreen();
        }

        private UserControl _CurrentScreen;

        public System.Windows.Controls.UserControl CurrentScreen
        {
            get
            {
                return _CurrentScreen;
            }
        }

        private void ChangeScreen(System.Windows.Controls.UserControl control)
        {
            _CurrentScreen = control;
            OnPropertyChanged("CurrentScreen");
        }

        public IScreen ShowCaptureNumeric(ScreenInput input)
        {
            inputScreen.UpdateScreen(input);
            ChangeScreen(inputScreen);
            return inputScreen;
        }

        public IScreen ShowMessage(ScreenInput input)
        {
            showMsgScreen.UpdateScreen(input);
            ChangeScreen(showMsgScreen);
            return showMsgScreen;
        }

        public IScreen ShowTwoChoices(ScreenInput input)
        {
            showTwoChoicesScreen.UpdateScreen(input);
            ChangeScreen(showTwoChoicesScreen);
            return showTwoChoicesScreen;
        }

        public void SetLanguage(string lang)
        {
            //code here to set language
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
